This patch adds a check in xend that prevents a user from trying to
authoremellor@ewan <emellor@ewan>
Thu, 22 Sep 2005 10:35:35 +0000 (11:35 +0100)
committeremellor@ewan <emellor@ewan>
Thu, 22 Sep 2005 10:35:35 +0000 (11:35 +0100)
destroy Dom0.  Currently, xm does not return an error for this case.
Xend tries to destroy dom0 and leaves the system in an unstable
state.  Subsequent attempts to create a domain result in the following
error message:

  Error: Error creating domain: (106, 'Transport endpoint is already \
  connected')

This will fix bugzilla bug #243

Signed-off-by: Dan Smith <danms@us.ibm.com>
tools/python/xen/xend/XendDomain.py

index 1f3b351681b1fa595cbdcd5beb3f31d92de8af82..76d4fce4a9e4f9111db07d2a692288854e31e6e6 100644 (file)
@@ -42,6 +42,7 @@ from xen.xend.xenstore.xsutil import GetDomainPath
 __all__ = [ "XendDomain" ]
 
 SHUTDOWN_TIMEOUT = 30
+PRIV_DOMAIN      =  0
 
 def is_dead(dom):
     return dom['crashed'] or dom['shutdown'] or (
@@ -163,7 +164,7 @@ class XendDomain:
         self.domain_restarts()
 
     def dom0_setup(self):
-        dom0 = self.domain_lookup(0)
+        dom0 = self.domain_lookup(PRIV_DOMAIN)
         if not dom0:
             dom0 = self.dom0_unknown()
         dom0.dom0_init_store()    
@@ -331,7 +332,7 @@ class XendDomain:
         return self.domains.get(id)
 
     def dom0_unknown(self):
-        dom0 = 0
+        dom0 = PRIV_DOMAIN
         uuid = None
         info = self.xen_domain(dom0)
         dompath = GetDomainPath(dom0)
@@ -499,6 +500,10 @@ class XendDomain:
 
         @param domid: domain id
         """
+
+        if domid == PRIV_DOMAIN:
+            raise XendError("Cannot destroy priviliged domain %i" % domid)
+        
         self.domain_restart_schedule(domid, reason, force=True)
         dominfo = self.domain_lookup(domid)
         if dominfo: